﻿
Imports std

Public Module extensions
    Public Function get_next(Of VECTOR_T)(ByVal i As vector(Of VECTOR_T)) As _do(Of VECTOR_T, Boolean)
        assert(Not i Is Nothing)
        Dim k As Int64 = 0
        Return Function(ByRef x As VECTOR_T) As Boolean
                   If k >= i.size() Then
                       Return False
                   Else
                       x = i(k)
                       k += 1
                       Return True
                   End If
               End Function
    End Function

    Public Function get_next(Of SET_T As IComparable(Of SET_T))(ByVal i As [set](Of SET_T)) As _do(Of SET_T, Boolean)
        assert(Not i Is Nothing)
        Dim it As [set](Of SET_T).iterator = Nothing
        it = i.begin()
        Return Function(ByRef x As SET_T) As Boolean
                   If it = i.end() Then
                       Return False
                   Else
                       x = (+it)
                       it += 1
                       Return True
                   End If
               End Function
    End Function
End Module
